// 导入
import { deviceEnquire, DEVICE_TYPE } from '@/plugins/device'
// 导入基本配置

// 引入vue想里面的mapGetters
import { mapGetters } from 'vuex'
const mixinDevice = {
  computed: mapGetters([
    'locale',
    'keepAlive',
    'device',
    'base',
    'color',
    'primaryColor',
    'token',
    'avatar',
    'nickname',
    'welcome',
    'roles',
    'userInfo',
    'addRouters',
    'multiTab',
    'theme',
    'layoutMode',
    'navTheme',
    'colorWeak',
    'fixedHeader',
    'fixSiderbar',
    'fixSidebar',
    'contentWidth',
    'autoHideHeader',
    'sidebarOpened',
    'isCollapse',
    'isFullScren',
    'isShade',
    'isLock',
    'showTag',
    'showDebug',
    'showCollapse',
    'showSearch',
    'showLock',
    'showFullScren',
    'showTheme',
    'showColor',
    'showMenu',
    'themeName',
    'lockPasswd',
    'screen',
    'jobTitle'
  ]),
  methods: {
    // 是否为移动设备
    isMobile () {
      return this.device === DEVICE_TYPE.MOBILE
    },
    // 是否为电脑设备
    isDesktop () {
      return this.device === DEVICE_TYPE.DESKTOP
    },
    // 是否为iPad设备
    isTablet () {
      return this.device === DEVICE_TYPE.TABLET
    },
    // 是否为电视终端设备
    isTV () {
      return this.device === DEVICE_TYPE.TV
    }

  }
}
/**
 * @description 根据对应数据类型设置显示样式
 */
const AppDeviceEnquire = {
  mounted () {
    // this.$store === {$store}
    const { $store } = this
    deviceEnquire(deviceType => {
      switch (deviceType) {
        // 电脑设备
        case DEVICE_TYPE.DESKTOP:
          $store.commit('app/TOGGLE_DEVICE', 'desktop')
          $store.dispatch('app/setSidebar', true)
          break
        // iPad设备
        case DEVICE_TYPE.TABLET:
          $store.commit('app/TOGGLE_DEVICE', 'tablet')
          $store.dispatch('app/setSidebar', false)
          break
        // 移动设备
        case DEVICE_TYPE.MOBILE:
          $store.commit('app/TOGGLE_DEVICE', 'mobile')
          $store.dispatch('app/setSidebar', true)
          break
        // 电视终端设备
        case DEVICE_TYPE.TV:
          $store.commit('app/TOGGLE_DEVICE', 'tv')
          $store.dispatch('app/setSidebar', true)
          break
      }
    })
  }
}
// 导出
export { AppDeviceEnquire, mixinDevice }
